#include "ParserUndo.h"

const string ParserUndo::undoKeyword = "undo";

ParserUndo::ParserUndo(ParserBase *_nextParser) : ParserBase (_nextParser) {
}

bool ParserUndo::tryParse(string userCommand, CommandBase* parsedCommand) {
	// stringstream to extract instruction
	stringstream wordExtractor(userCommand);
	string command;

	wordExtractor >> command;
	wordExtractor >> ws;

	bool isSuccess = (!wordExtractor.fail() &&
					  wordExtractor.eof() &&
					  // ensure that string compare is not case sensitive
					  boost::iequals(command, undoKeyword));

	if (isSuccess) {
		//parsedCommand 
		//parsedCommand.commandType = UNDO;
		parsedCommand = new CommandUndo();
	}else {
		//parsedCommand.commandType = INVALID;
	}

	return isSuccess;
}